package com.cfpl.admin_vegetable_service.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cfpl.admin_vegetable_service.DTO.VegNameAndPlantLocationDTO;
import com.cfpl.admin_vegetable_service.VO.QualityInspectionPageVO;
import com.cfpl.admin_vegetable_service.mapper.QualityInspectionRecordMapper;
import com.cfpl.admin_vegetable_service.service.QualityInspectionRecordService;
import com.cfpl.project_common.context.BaseContext;
import com.cfpl.project_common.pojo.QualityInspectionRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author 14720
* @description 针对表【quality_inspection_record(质量检查记录表)】的数据库操作Service实现
* @createDate 2023-11-02 10:16:29
*/
@Service
public class QualityInspectionRecordServiceImpl extends ServiceImpl<QualityInspectionRecordMapper, QualityInspectionRecord>
    implements QualityInspectionRecordService {

    @Autowired
    private QualityInspectionRecordMapper qualityInspectionRecordMapper;
    /**
     * 分页查询质量检测记录
     * @param page  分页信息
     * @param condition  查询条件
     * @return  质量检测记录
     */
    @Override
    public Page<QualityInspectionPageVO> queryPage(IPage<QualityInspectionPageVO> page, String condition) {
        return qualityInspectionRecordMapper.pageQueryByCondition(page, condition);
    }
    /**
     * 添加质量检测记录
     * @param qualityInspectionRecord 质量检测记录对象
     * @return
     */
    @Override
    public void addQualityInspectionRecord(QualityInspectionRecord qualityInspectionRecord) {
//        qualityInspectionRecord.setDetectionTime(new Date());
        qualityInspectionRecordMapper.insertQualityInspectionRecord(qualityInspectionRecord);
    }
    /**
     * 根据样品编号（进场批次）查询果蔬名称和种植地
     * @param sampleNumber  样品编号
     * @return
     */
    @Override
    public VegNameAndPlantLocationDTO queryBySampleNumber(String sampleNumber) {
        return qualityInspectionRecordMapper.queryBySampleNumber(sampleNumber);
    }
    /**
     * 根据质量检测id查询单条记录
     * @param id  质量检测id
     * @return 质量检测单条记录
     */
    @Override
    public QualityInspectionRecord queryQualityInspectionRecordById(Long id) {
        return qualityInspectionRecordMapper.selectById(id);
    }
}




